<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>ESP8266_RTOS_SDK: include/espressif/spi_flash.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ESP8266_RTOS_SDK
   &#160;<span id="projectnumber">v1.4.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_cf4dbf1328d2cf10d3f3933741525dc7.html">espressif</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">spi_flash.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * ESPRSSIF MIT License</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Copyright (c) 2015 &lt;ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * it is free of charge, to any person obtaining a copy of this software and associated</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> * documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the Software is furnished</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * to do so, subject to the following conditions:</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> * The above copyright notice and this permission notice shall be included in all copies or</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * substantial portions of the Software.</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#ifndef __SPI_FLASH_H__</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#define __SPI_FLASH_H__</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">   48</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
<div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea8c0e5ba08fbb8fbe8f5f1a6eac6e01cc">   49</a></span>&#160;    <a class="code" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea8c0e5ba08fbb8fbe8f5f1a6eac6e01cc">SPI_FLASH_RESULT_OK</a>,        </div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea6a7e104b6106ddf6a7fa6e2fbe93edca">   50</a></span>&#160;    <a class="code" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea6a7e104b6106ddf6a7fa6e2fbe93edca">SPI_FLASH_RESULT_ERR</a>,       </div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea266272773eeee7e649575a8ad4f5d119">   51</a></span>&#160;    <a class="code" href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea266272773eeee7e649575a8ad4f5d119">SPI_FLASH_RESULT_TIMEOUT</a>    </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;} <a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a>;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="structSpiFlashChip.html">   54</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct</span>{</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    uint32  deviceId;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    uint32  chip_size;    <span class="comment">// chip size in byte</span></div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    uint32  block_size;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    uint32  sector_size;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    uint32  page_size;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    uint32  status_mask;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;} <a class="code" href="structSpiFlashChip.html">SpiFlashChip</a>;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#ga518257817c69fec25290c1bebad544b0">   63</a></span>&#160;<span class="preprocessor">#define SPI_FLASH_SEC_SIZE  4096    </span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="preprocessor">uint32 spi_flash_get_id(void);</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> <a class="code" href="group__SPI__Driver__APIs.html#ga8bd9176a0db21f8a04c0ab8792b74fec">spi_flash_read_status</a>(uint32 *status);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> <a class="code" href="group__SPI__Driver__APIs.html#ga0e1358b06ac94b1e94c6aec83d034c56">spi_flash_write_status</a>(uint32 status_value);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> <a class="code" href="group__SPI__Driver__APIs.html#ga3210ddd52247977cff3d018bf34f9048">spi_flash_erase_sector</a>(uint16 sec);</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> <a class="code" href="group__SPI__Driver__APIs.html#ga97906813255238cdb0da4d21040abf90">spi_flash_write</a>(uint32 des_addr, uint32 *src_addr, uint32 size);</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;<a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> <a class="code" href="group__SPI__Driver__APIs.html#gacfd871ce143884d5c3dfb456024b0096">spi_flash_read</a>(uint32 src_addr, uint32 *des_addr, uint32 size);</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;</div>
<div class="line"><a name="l00135"></a><span class="lineno"><a class="line" href="group__SPI__Driver__APIs.html#gacda8d0eb9ddb859ea21726108d825f17">  135</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a> (* <a class="code" href="group__SPI__Driver__APIs.html#gacda8d0eb9ddb859ea21726108d825f17">user_spi_flash_read</a>)(</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <a class="code" href="structSpiFlashChip.html">SpiFlashChip</a> *spi,</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        uint32 src_addr,</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        uint32 *des_addr,</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        uint32 size);</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__SPI__Driver__APIs.html#ga826a3caeec9fd019d6a30c3113d1547e">spi_flash_set_read_func</a>(<a class="code" href="group__SPI__Driver__APIs.html#gacda8d0eb9ddb859ea21726108d825f17">user_spi_flash_read</a> read);</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;}</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="structSpiFlashChip_html"><div class="ttname"><a href="structSpiFlashChip.html">SpiFlashChip</a></div><div class="ttdef"><b>Definition:</b> spi_flash.h:54</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga0e1358b06ac94b1e94c6aec83d034c56"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga0e1358b06ac94b1e94c6aec83d034c56">spi_flash_write_status</a></div><div class="ttdeci">SpiFlashOpResult spi_flash_write_status(uint32 status_value)</div><div class="ttdoc">Write state register of SPI Flash. </div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_gacfd871ce143884d5c3dfb456024b0096"><div class="ttname"><a href="group__SPI__Driver__APIs.html#gacfd871ce143884d5c3dfb456024b0096">spi_flash_read</a></div><div class="ttdeci">SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size)</div><div class="ttdoc">Read data from Flash. </div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_gga7546515bb162fd2bb252ebe20fd92dbea6a7e104b6106ddf6a7fa6e2fbe93edca"><div class="ttname"><a href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea6a7e104b6106ddf6a7fa6e2fbe93edca">SPI_FLASH_RESULT_ERR</a></div><div class="ttdef"><b>Definition:</b> spi_flash.h:50</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga3210ddd52247977cff3d018bf34f9048"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga3210ddd52247977cff3d018bf34f9048">spi_flash_erase_sector</a></div><div class="ttdeci">SpiFlashOpResult spi_flash_erase_sector(uint16 sec)</div><div class="ttdoc">Erase the Flash sector. </div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_gga7546515bb162fd2bb252ebe20fd92dbea266272773eeee7e649575a8ad4f5d119"><div class="ttname"><a href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea266272773eeee7e649575a8ad4f5d119">SPI_FLASH_RESULT_TIMEOUT</a></div><div class="ttdef"><b>Definition:</b> spi_flash.h:51</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga97906813255238cdb0da4d21040abf90"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga97906813255238cdb0da4d21040abf90">spi_flash_write</a></div><div class="ttdeci">SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size)</div><div class="ttdoc">Write data to Flash. </div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga7546515bb162fd2bb252ebe20fd92dbe"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga7546515bb162fd2bb252ebe20fd92dbe">SpiFlashOpResult</a></div><div class="ttdeci">SpiFlashOpResult</div><div class="ttdef"><b>Definition:</b> spi_flash.h:48</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_gacda8d0eb9ddb859ea21726108d825f17"><div class="ttname"><a href="group__SPI__Driver__APIs.html#gacda8d0eb9ddb859ea21726108d825f17">user_spi_flash_read</a></div><div class="ttdeci">SpiFlashOpResult(* user_spi_flash_read)(SpiFlashChip *spi, uint32 src_addr, uint32 *des_addr, uint32 size)</div><div class="ttdoc">Registered function for spi_flash_set_read_func. </div><div class="ttdef"><b>Definition:</b> spi_flash.h:135</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga8bd9176a0db21f8a04c0ab8792b74fec"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga8bd9176a0db21f8a04c0ab8792b74fec">spi_flash_read_status</a></div><div class="ttdeci">SpiFlashOpResult spi_flash_read_status(uint32 *status)</div><div class="ttdoc">Read state register of SPI Flash. </div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_gga7546515bb162fd2bb252ebe20fd92dbea8c0e5ba08fbb8fbe8f5f1a6eac6e01cc"><div class="ttname"><a href="group__SPI__Driver__APIs.html#gga7546515bb162fd2bb252ebe20fd92dbea8c0e5ba08fbb8fbe8f5f1a6eac6e01cc">SPI_FLASH_RESULT_OK</a></div><div class="ttdef"><b>Definition:</b> spi_flash.h:49</div></div>
<div class="ttc" id="group__SPI__Driver__APIs_html_ga826a3caeec9fd019d6a30c3113d1547e"><div class="ttname"><a href="group__SPI__Driver__APIs.html#ga826a3caeec9fd019d6a30c3113d1547e">spi_flash_set_read_func</a></div><div class="ttdeci">void spi_flash_set_read_func(user_spi_flash_read read)</div><div class="ttdoc">Register user-define SPI flash read API. </div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Tue Mar 1 2016 10:19:26 for ESP8266_RTOS_SDK by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.10
</small></address>
</body>
</html>
